package com.iwhalecloud.bss.kite.cucc.web.service.accept.handler.attr;

import com.iwhalecloud.bss.kite.client.api.scene.operate.IOperateSceneCommonService;
import com.iwhalecloud.bss.kite.client.dto.DataResult;
import com.iwhalecloud.bss.kite.client.vo.scene.CommonAttrVO;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.client.api.inst.IProdInstService;
import com.iwhalecloud.bss.kite.manager.api.IOperateSceneInstService;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.web.context.KiteWebContext;
import com.iwhalecloud.bss.kite.web.service.accept.attr.handler.AbstractAttrHandler;
import com.ztesoft.bss.common.util.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IsVIKHandler extends AbstractAttrHandler {

    @Autowired
    private IOperateSceneInstService operateSceneInstService;

    @Autowired
    private IQuerySceneInstService querySceneInstService;

    @Autowired
    public IProdInstService prodInstService;

    @Override
    public void init(CommonAttrVO commonAttr) {

    }

    @Override
    public DataResult<Boolean> apply(String sceneInstId, String fieldName, String value, String valueDesc) {
        if (KiteStringUtils.isEqual("ORD10160", fieldName)) {
            KiteAttr attr = querySceneInstService
                .getCommonAttrsByFieldName(sceneInstId, "ORD10161", "93");
            if (KiteStringUtils.isEqual("1", value)) {
                attr.setIsNull("F");
            } else {
                attr.setIsNull("T");
            }
            SpringUtil.getBean(IOperateSceneCommonService.class).setCommonAttr(KiteWebContext.getContext().getCurrentSceneInstId(), attr);
        }
        return super.apply(sceneInstId, fieldName, value, valueDesc);
    }

}
